import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';

// https://vitejs.dev/config/
export default defineConfig({
    server: {
        host: true,
        open: true,
        port: 5173,
        proxy: {
            '/api': {
                target: 'http://tp.ywtest.com/',
                changeOrigin: true,
                // rewrite: (path) => path.replace(/^\/api/, ''),
            },
        },
    },
    build: {
        // outDir: '../server/public/',
        // minify: false,
        // chunkSizeWarningLimit: 1500,
        rollupOptions: {
            output: {
                manualChunks: id => {
                    if (id.includes('node_modules')) {
                        return 'vendor';
                    }
                }
            }
        }
    },
    plugins: [
        vue(),
        viteCompression({
            threshold: 1000 * 1024
        })
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})
